/***************
 * Project Outcomes Panel
 */
AIR2.Project.Outcomes = function() {
    return new AIR2.UI.Panel({
        colspan: 1,
        title: 'Outcomes',
        showTotal: true,
        iconCls: 'air2-project-outcome-icon',
        storeData: AIR2.Project.OUTDATA,
        url: AIR2.Project.BASEURL + '/outcomes',
        itemSelector: '.air2-project-outcomes-row',
        tpl: new Ext.XTemplate(
            '<table><tpl for=".">' +
              '<tr class="air2-project-outcomes-row">' +
                '<td><a href="{prjo_link}">{prjo_headline:ellipsis(60)}</td>' +
                '<td>{[AIR2.Format.userName(values.CreUser, true)]}</td>' +
              '</tr>' +
            '</tpl></table>',
            {compiled: true, disableFormats: true}
        ),
        editModal: {
            allowAdd: AIR2.Project.SUMMDATA.authz.may_write,
            items: {
                xtype: 'air2liveeditor',
                url: AIR2.Project.BASEURL + '/outcomes',
                sortField: 'prjo_dtim',
                sortDir: 'ASC',
                pageSize: 50,
                allowEdit: AIR2.Project.SUMMDATA.authz.may_write,
                allowDelete: AIR2.Project.SUMMDATA.authz.may_write,
                hideButtons: true,
                editForm: {
                    labelAlign: 'top',
                    items: [{
                        xtype: 'container',
                        layout: 'column',
                        items: [{
                            xtype: 'container',
                            columnWidth: .75,
                            layout: 'form',
                            items: {
                                xtype: 'textfield',
                                fieldLabel: 'Headline',
                                name: 'prjo_headline',
                                allowBlank: false,
                                width: '95%'
                            }
                        },{
                            xtype: 'container',
                            columnWidth: .25,
                            layout: 'form',
                            items: {
                                xtype: 'datefield',
                                fieldLabel: 'Date',
                                width: 100,
                                name: 'prjo_dtim',
                                allowBlank: false
                            }
                        }]
                    },{
                        xtype: 'textfield',
                        fieldLabel: 'Link',
                        allowBlank: false,
                        vtype: 'url',
                        name: 'prjo_link'
                    },{
                        xtype: 'textarea',
                        fieldLabel: 'Teaser',
                        name: 'prjo_teaser',
                        allowBlank: false,
                        grow: true,
                        growMin: 60
                    }]
                },
                tpl: new Ext.XTemplate(
                    '<div class="air2-project-outcome">' +
                      '<h3><a class="title" href="{prjo_link}">{prjo_headline}</a>' +
                      '<span class="date"> - {[AIR2.Format.date(values.prjo_dtim)]}</span></h3>' +
                      '<div class="teaser">{prjo_teaser}</div>' +
                      '<div class="meta"><span class="datewho">' +
                        '<tpl if="UpdUser">Updated ' +
                          '{[AIR2.Format.date(values.prjo_upd_dtim)]} by ' +
                          '{[AIR2.Format.userName(values.CreUser, true)]}' +
                        '</tpl>' +
                        '<tpl if="!UpdUser">Created ' +
                          '{[AIR2.Format.date(values.prjo_cre_dtim)]} by ' +
                          '{[AIR2.Format.userName(values.UpdUser, true)]}' +
                        '</tpl></span>' +
                        '<button class="air2-rowedit"></button>' +
                        '<button class="air2-rowdelete"></button>' +
                      '</div>' +
                    '</div>',
                    {compiled: true, disableFormats: true}
                )
            }
        }
    });
}